package com.ruoyi.project.play.serviceItem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.play.serviceItem.domain.ServiceObjectItem;
import com.ruoyi.project.play.serviceItem.service.IServiceObjectItemService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 项目付费条目Controller
 * 
 * @author wyh
 * @date 2024-07-08
 */
@RestController
@RequestMapping("/play/serviceItem")
public class ServiceObjectItemController extends BaseController
{
    @Autowired
    private IServiceObjectItemService serviceObjectItemService;

    /**
     * 查询项目付费条目列表
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceObjectItem serviceObjectItem)
    {
        startPage();
        List<ServiceObjectItem> list = serviceObjectItemService.selectServiceObjectItemList(serviceObjectItem);
        return getDataTable(list);
    }

    /**
     * 导出项目付费条目列表
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:export')")
    @Log(title = "项目付费条目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceObjectItem serviceObjectItem)
    {
        List<ServiceObjectItem> list = serviceObjectItemService.selectServiceObjectItemList(serviceObjectItem);
        ExcelUtil<ServiceObjectItem> util = new ExcelUtil<ServiceObjectItem>(ServiceObjectItem.class);
        util.exportExcel(response, list, "项目付费条目数据");
    }

    /**
     * 获取项目付费条目详细信息
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serviceObjectItemService.selectServiceObjectItemById(id));
    }

    /**
     * 新增项目付费条目
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:add')")
    @Log(title = "项目付费条目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceObjectItem serviceObjectItem)
    {
        return toAjax(serviceObjectItemService.insertServiceObjectItem(serviceObjectItem));
    }

    /**
     * 修改项目付费条目
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:edit')")
    @Log(title = "项目付费条目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceObjectItem serviceObjectItem)
    {
        return toAjax(serviceObjectItemService.updateServiceObjectItem(serviceObjectItem));
    }

    /**
     * 删除项目付费条目
     */
    @PreAuthorize("@ss.hasPermi('play:serviceItem:remove')")
    @Log(title = "项目付费条目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceObjectItemService.deleteServiceObjectItemByIds(ids));
    }
}
